package com.jinxiangyang.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jinxiangyang.domain.UserInfo;
import com.jinxiangyang.mapper.UserInfoMapper;
import com.jinxiangyang.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author jinxiangyang
 * @since 2023-08-12
 */
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;
    @Override
    public IPage<UserInfo> getPageUserInfoLike(Integer currentPage, Integer pageSize, UserInfo userInfo) {
        IPage<UserInfo> ipage = new Page<>(currentPage,pageSize);
        QueryWrapper<UserInfo> qw = new QueryWrapper<>();
        if (userInfo != null) {
            if (!("").equals(userInfo.getNickName()) && userInfo.getNickName() != null) {
                qw.like("nick_name", userInfo.getNickName());
            }
            if (!("").equals(userInfo.getSex()) && userInfo.getSex() != null) {
                qw.like("sex", userInfo.getSex());
            }
            if (!("").equals(userInfo.getPhone()) && userInfo.getNickName() != null) {
                qw.like("phone", userInfo.getPhone());
            }
        }
        IPage<UserInfo> userInfoIPage = userInfoMapper.selectPage(ipage, qw);
        return userInfoIPage;
    }



}
